<template>
	<view>
		<jinEdit :html="detail" placeholder="请输入内容" :formData="formData" fileKeyName="image" :header="header" @editOk="editOk" :uploadFileUrl="action"></jinEdit>
	</view>
</template>

<script>
	import jinEdit from '@/components/jin-edit/jin-edit.vue';
	import api from '@/common/uploadApi'
	export default {
		data() {
			return {
				action:api.imageDetail,
				header: {
					"Authorization": 'Bearer ' + uni.getStorageSync('token')
				},
				formData:{
					product_id:'',
				},
				detail:''
			}
		},
		components: {
			jinEdit
		},
		onLoad(option) {
			this.formData.product_id = option.id;
			this.getGoodsDetail();
		},
		methods: {
			getGoodsDetail(){
				this.$u.api.goodsDetails({
					id: this.formData.product_id
				}).then(res => {
					if (res.code == 0) {
						this.detail = res.data.details;
					}
				})
			},
			// 点击发布
			editOk(data) {
				this.$u.api.mediaDetails({
					details:data.html,
					id:this.formData.product_id
				}).then(res=>{
					let pages = getCurrentPages();
					let currPage = pages[pages.length-2];
					currPage.$vm.detail = data.html;
					uni.navigateBack();
				})
				
			}
		}
	}
</script>

<style scoped lang="scss">

</style>
